import request from '@/utils/request'
import dateApi from '@/utils/date'

export default {
    search(searchMap) {
        console.log(searchMap.value2[0]);
        console.log(searchMap);
        if (searchMap.value2 == "") {
            if (searchMap.operator == "") {
                const req = request({
                    method: 'get',
                    url: '/dgut/getAllLogs'
                })
                return req;
            } else {
                const req = request({
                    method: 'get',
                    url: '/dgut/getLogsByName',
                    params: {
                        operator: searchMap.operator
                    }
                })
                return req;
            }
        } else {
            var date1 = new Date(searchMap.value2[0]);
            var date2 = new Date(searchMap.value2[1]);
            var begindate = dateApi.getDate(date1);
            var enddate = dateApi.getDate(date2);
            if (searchMap.operator == "") {
                const reqs = request({
                    method: 'get',
                    url: '/dgut/getLogsByTime',
                    params: {
                        begindate, enddate
                    },
                })
                return reqs;
            } else {
                const reqs = request({
                    method: 'get',
                    url: '/dgut/getLogsByNameAndTime',
                    params: {
                        operator: searchMap.operator,
                        begindate, enddate
                    },
                })
                return reqs;
            }

        }

    }
}